// import store from "@/store";

// 预售商品发货方式
export function getPresalesDelivery(goodInfo = {}) {
	// 判断是否为预售
	const isPresell = goodInfo.saleType == 3 || (goodInfo.stocks == 0 && goodInfo.saleType == 2) || (goodInfo.stocks ==
		0 &&
		goodInfo.prepareStocks > 0) || goodInfo.presellOn == 1
	if (goodInfo && (isPresell || goodInfo.openStatus3) && goodInfo.prepareDeliveryTime) {
		let monthPart
		const prepareDeliveryTimeComponent = goodInfo.prepareDeliveryTime.split(',')
		const month = prepareDeliveryTimeComponent[0].split('-')[1]
		switch (Number(prepareDeliveryTimeComponent[2])) {
			case 1:
				monthPart = "上旬"
				break;
			case 2:
				monthPart = "中旬"
				break;
			case 3:
				monthPart = "下旬"
				break;
		}
		return `预售，${Number(month)}月${monthPart}发货`
	} else if (goodInfo && (isPresell || goodInfo.openStatus3) && goodInfo.deliveryMsg) {
		if (goodInfo.deliveryTimeType == 0) {
			let time = goodInfo.deliveryMsg.split('-')[0] + '年' + goodInfo.deliveryMsg.split('-')[1] + '月' + goodInfo
				.deliveryMsg.split('-')[2] + '日后开始发货'
			return time
		} else {
			return goodInfo.deliveryMsg
		}
	}
	return false


}
